package com.Iconcat.system.service.impl;

import com.Iconcat.system.entity.CatProject;
import com.Iconcat.system.entity.MovieProject;
import com.Iconcat.system.mapper.CatProjectMapper;
import com.Iconcat.system.service.CatProjectService;
import com.Iconcat.system.service.MovieProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CatProjecServiceImpl extends ServiceImpl<CatProjectMapper, CatProject> implements CatProjectService {

    @Resource
    private MovieProjectService movieProjectService;

    @Resource
    private CatProjectMapper catProjectMapper;
    @Override
    public void addCatProjecWithMovieProject(CatProject catProject) {
        // 保存 CatProjec
        save(catProject);

        // 创建对应的 MovieProject 对象，设置相应的属性值
        MovieProject movieProject = new MovieProject();
        BeanUtils.copyProperties(catProject, movieProject);
        // 其他设置...

        // 调用 MovieProjectService 添加 MovieProject
        movieProjectService.addMovieProject(movieProject);
    }
    @Override
    public List<CatProject> getAllProjects() {
        return baseMapper.getAllProjects();
    }

    @Override
    public CatProject selectedSById(Integer projectId) {
        return catProjectMapper.selectedSById(projectId);
    }

    @Override
    public void updateIsHiddenById(Integer id, Boolean isHidden) {
        catProjectMapper.updateIsHiddenById(id, isHidden);
    }

    @Override
    public boolean deleteUserById(Integer id) {
        return  catProjectMapper.deleteUserById(id);
    }

    @Override
    public boolean updateUserById(CatProject catProject) {
      return catProjectMapper.updateUserById(catProject);
    }
}
